import { merge } from 'lodash';
import { TransactionType } from '@metamask/transaction-controller';

import {
  buildApproveTransactionData,
  buildDecreaseAllowanceTransactionData,
  buildIncreaseAllowanceTransactionData,
  buildSetApproveForAllTransactionData,
  buildPermit2ApproveTransactionData,
} from '../helpers/approve';
import { ZERO_ADDRESS } from '../../constants/address';

export const transactionIdMock = '699ca2f0-e459-11ef-b6f6-d182277cf5e1';
const permit2TokenMock = '0x1234567890123456789012345678901234567890';

export const approvalSpenderMock = '0x9876543210987654321098765432109876543210';
export const shortenedSpenderMock = '0x98765...43210';
export const tokenAddressMock = '0x97cb1fdd071da9960d38306c07f146bc98b2d317';
export const shortenedTokenAddressMock = '0x97cb1...2D317';

const baseTransactionMock = {
  actionId: undefined,
  batchId: undefined,
  chainId: '0x1',
  customNonceValue: '1',
  dappSuggestedGasFees: {
    maxFeePerGas: '0xcdfe60',
    maxPriorityFeePerGas: '0x012345',
  },
  defaultGasEstimates: {
    estimateType: 'medium',
    gas: '0x664e',
    gasPrice: undefined,
    maxFeePerGas: '0xcdfe60',
    maxPriorityFeePerGas: '0x0',
  },
  delegationAddress: undefined,
  deviceConfirmedOn: undefined,
  disableGasBuffer: undefined,
  gasFeeEstimates: {
    high: { maxFeePerGas: '0x1036640', maxPriorityFeePerGas: '0x0' },
    low: { maxFeePerGas: '0x989680', maxPriorityFeePerGas: '0x0' },
    medium: { maxFeePerGas: '0xcdfe60', maxPriorityFeePerGas: '0x0' },
    type: 'fee-market',
  },
  gasFeeEstimatesLoaded: true,
  gasFeeTokens: [],
  gasLimitNoBuffer: '0x664e',
  id: transactionIdMock,
  isFirstTimeInteraction: undefined,
  nestedTransactions: undefined,
  networkClientId: 'adb18d66-c112-449b-9f0c-c3664f6414bf',
  origin: 'metamask',
  originalGasEstimate: '0x664e',
  securityAlertResponse: undefined,
  simulationData: { nativeBalanceChange: undefined, tokenBalanceChanges: [] },
  simulationFails: undefined,
  status: 'unapproved',
  time: 1746696740463,
  txParams: {
    data: '0x',
    from: '0xdc47789de4ceff0e8fe9d15d728af7f17550c164',
    gas: '0x664e',
    maxFeePerGas: '0xcdfe60',
    maxPriorityFeePerGas: '0x012345',
    to: tokenAddressMock,
    type: '0x2',
  },
  type: 'simpleSend',
  userEditedGasLimit: false,
  userFeeLevel: 'dappSuggested',
  verifiedOnBlockchain: false,
};

const baseTransactionControllerMock = {
  engine: {
    backgroundState: {
      TransactionController: {
        transactions: [],
        transactionBatches: [],
        methodData: {},
        lastFetchedBlockNumbers: {},
        submitHistory: [],
      },
    },
  },
};

export const simpleSendTransaction = merge({}, baseTransactionMock, {
  id: transactionIdMock,
  txParams: {
    value: '0x0',
  },
});

const baseApproveTransaction = merge({}, baseTransactionMock, {
  id: transactionIdMock,
  type: TransactionType.tokenMethodApprove,
  txParams: {
    data: '',
  },
});

export const contractDeploymentTransaction = merge({}, baseTransactionMock, {
  id: transactionIdMock,
  type: TransactionType.deployContract,
  txParams: {
    from: '0xdc47789de4ceff0e8fe9d15d728af7f17550c164',
    data: '0x6101406040523480156200001257600080fd5b506040516200323e3803806200323e83398181016040528101906200003891906200065b565b82806040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525085848682600390816200008491906200094c565b5081600490816200009691906200094c565b5080600560006101000a81548160ff021916908360ff160217905550505050620000d5620000c9620001ce60201b60201c565b620001d660201b60201c565b60008280519060200120905060008280519060200120905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e081815250508161010081815250504660a081815250506200013e8184846200029c60201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff1681525050806101208181525050505050505050620001c433600560009054906101000a900460ff16600a620001ab919062000bb6565b86620001b8919062000c07565b620002d860201b60201c565b5050505062000dfb565b600033905090565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008383834630604051602001620002b995949392919062000cc3565b6040516020818303038152906040528051906020012090509392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036200034a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620003419062000d81565b60405180910390fd5b6200035e600083836200044560201b60201c565b806002600082825462000372919062000da3565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405162000425919062000dde565b60405180910390a362000441600083836200044a60201b60201c565b5050565b505050565b505050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b620004788162000463565b81146200048457600080fd5b50565b60008151905062000498816200046d565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620004f382620004a8565b810181811067ffffffffffffffff82111715620005155762000514620004b9565b5b80604052505050565b60006200052a6200044f565b9050620005388282620004e8565b919050565b600067ffffffffffffffff8211156200055b576200055a620004b9565b5b6200056682620004a8565b9050602081019050919050565b60005b838110156200059357808201518184015260208101905062000576565b60008484015250505050565b6000620005b6620005b0846200053d565b6200051e565b905082815260208101848484011115620005d557620005d4620004a3565b5b620005e284828562000573565b509392505050565b600082601f8301126200060257620006016200049e565b5b8151620006148482602086016200059f565b91505092915050565b600060ff82169050919050565b62000635816200061d565b81146200064157600080fd5b50565b60008151905062000655816200062a565b92915050565b6000806000806080858703121562000678576200067762000459565b5b6000620006888782880162000487565b945050602085015167ffffffffffffffff811115620006ac57620006ab6200045e565b5b620006ba87828801620005ea565b9350506040620006cd8782880162000644565b925050606085015167ffffffffffffffff811115620006f157620006f06200045e565b5b620006ff87828801620005ea565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200075e57607f821691505b60208210810362000774576200077362000716565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620007de7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200079f565b620007ea86836200079f565b95508019841693508086168417925050509392505050565b6000819050919050565b60006200082d62000827620008218462000463565b62000802565b62000463565b9050919050565b6000819050919050565b62000849836200080c565b62000861620008588262000834565b848454620007ac565b825550505050565b600090565b6200087862000869565b620008858184846200083e565b505050565b5b81811015620008ad57620008a16000826200086e565b6001810190506200088b565b5050565b601f821115620008fc57620008c6816200077a565b620008d1846200078f565b81016020851015620008e1578190505b620008f9620008f0856200078f565b8301826200088a565b50505b505050565b600082821c905092915050565b6000620009216000198460080262000901565b1980831691505092915050565b60006200093c83836200090e565b9150826002028217905092915050565b62000957826200070b565b67ffffffffffffffff811115620009735762000972620004b9565b5b6200097f825462000745565b6200098c828285620008b1565b600060209050601f831160018114620009c45760008415620009af578287015190505b620009bb85826200092e565b86555062000a2b565b601f198416620009d4866200077a565b60005b82811015620009fe57848901518255600182019150602085019450602081019050620009d7565b8683101562000a1e578489015162000a1a601f8916826200090e565b8355505b6001600288020188555050505b505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008160011c9050919050565b6000808291508390505b600185111562000ac15780860481111562000a995762000a9862000a33565b5b600185161562000aa95780820291505b808102905062000ab98562000a62565b945062000a79565b94509492505050565b60008262000adc576001905062000baf565b8162000aec576000905062000baf565b816001811462000b05576002811462000b105762000b46565b600191505062000baf565b60ff84111562000b255762000b2462000a33565b5b8360020a91508482111562000b3f5762000b3e62000a33565b5b5062000baf565b5060208310610133831016604e8410600b841016171562000b805782820a90508381111562000b7a5762000b7962000a33565b5b62000baf565b62000b8f848484600162000a6f565b9250905081840481111562000ba95762000ba862000a33565b5b81810290505b9392505050565b600062000bc38262000463565b915062000bd0836200061d565b925062000bff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848462000aca565b905092915050565b600062000c148262000463565b915062000c218362000463565b925082820262000c318162000463565b9150828204841483151762000c4b5762000c4a62000a33565b5b5092915050565b6000819050919050565b62000c678162000c52565b82525050565b62000c788162000463565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600062000cab8262000c7e565b9050919050565b62000cbd8162000c9e565b82525050565b600060a08201905062000cda600083018862000c5c565b62000ce9602083018762000c5c565b62000cf8604083018662000c5c565b62000d07606083018562000c6d565b62000d16608083018462000cb2565b9695505050505050565b600082825260208201905092915050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600062000d69601f8362000d20565b915062000d768262000d31565b602082019050919050565b6000602082019050818103600083015262000d9c8162000d5a565b9050919050565b600062000db08262000463565b915062000dbd8362000463565b925082820190508082111562000dd85762000dd762000a33565b5b92915050565b600060208201905062000df5600083018462000c6d565b92915050565b60805160a05160c05160e05161010051610120516123f362000e4b6000396000610ed901526000610f1b01526000610efa01526000610e2f01526000610e8501526000610eae01526123f36000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063715018a6116100a2578063a457c2d711610071578063a457c2d7146102e5578063a9059cbb14610315578063d505accf14610345578063dd62ed3e14610361578063f2fde38b1461039157610116565b8063715018a61461026f5780637ecebe00146102795780638da5cb5b146102a957806395d89b41146102c757610116565b8063313ce567116100e9578063313ce567146101b75780633644e515146101d557806339509351146101f357806340c10f191461022357806370a082311461023f57610116565b806306fdde031461011b578063095ea7b31461013957806318160ddd1461016957806323b872dd14610187575b600080fd5b6101236103ad565b60405161013091906115f5565b60405180910390f35b610153600480360381019061014e91906116b0565b61043f565b604051610160919061170b565b60405180910390f35b610171610462565b60405161017e9190611735565b60405180910390f35b6101a1600480360381019061019c9190611750565b61046c565b6040516101ae919061170b565b60405180910390f35b6101bf61049b565b6040516101cc91906117bf565b60405180910390f35b6101dd6104ae565b6040516101ea91906117f3565b60405180910390f35b61020d600480360381019061020891906116b0565b6104bd565b60405161021a919061170b565b60405180910390f35b61023d600480360381019061023891906116b0565b6104f4565b005b6102596004803603810190610254919061180e565b61050a565b6040516102669190611735565b60405180910390f35b610277610552565b005b610293600480360381019061028e919061180e565b610566565b6040516102a09190611735565b60405180910390f35b6102b16105b6565b6040516102be919061184a565b60405180910390f35b6102cf6105e0565b6040516102dc91906115f5565b60405180910390f35b6102ff60048036038101906102fa91906116b0565b610672565b60405161030c919061170b565b60405180910390f35b61032f600480360381019061032a91906116b0565b6106e9565b60405161033c919061170b565b60405180910390f35b61035f600480360381019061035a91906118bd565b61070c565b005b61037b6004803603810190610376919061195f565b61084e565b6040516103889190611735565b60405180910390f35b6103ab60048036038101906103a6919061180e565b6108d5565b005b6060600380546103bc906119ce565b80601f01602080910402602001604051908101604052809291908181526020018280546103e8906119ce565b80156104355780601f1061040a57610100808354040283529160200191610435565b820191906000526020600020905b81548152906001019060200180831161041857829003601f168201915b5050505050905090565b60008061044a610958565b9050610457818585610960565b600191505092915050565b6000600254905090565b600080610477610958565b9050610484858285610b29565b61048f858585610bb5565b60019150509392505050565b600560009054906101000a900460ff1681565b60006104b8610e2b565b905090565b6000806104c8610958565b90506104e98185856104da858961084e565b6104e49190611a2e565b610960565b600191505092915050565b6104fc610f45565b6105068282610fc3565b5050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61055a610f45565b6105646000611119565b565b60006105af600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206111df565b9050919050565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546105ef906119ce565b80601f016020809104026020016040519081016040528092919081815260200182805461061b906119ce565b80156106685780601f1061063d57610100808354040283529160200191610668565b820191906000526020600020905b81548152906001019060200180831161064b57829003601f168201915b5050505050905090565b60008061067d610958565b9050600061068b828661084e565b9050838110156106d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c790611ad4565b60405180910390fd5b6106dd8286868403610960565b60019250505092915050565b6000806106f4610958565b9050610701818585610bb5565b600191505092915050565b8342111561074f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074690611b40565b60405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c988888861077e8c6111ed565b8960405160200161079496959493929190611b60565b60405160208183030381529060405280519060200120905060006107b78261124b565b905060006107c782878787611265565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610837576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082e90611c0d565b60405180910390fd5b6108428a8a8a610960565b50505050505050505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6108dd610f45565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361094c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094390611c9f565b60405180910390fd5b61095581611119565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036109cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c690611d31565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3590611dc3565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610b1c9190611735565b60405180910390a3505050565b6000610b35848461084e565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610baf5781811015610ba1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9890611e2f565b60405180910390fd5b610bae8484848403610960565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c1b90611ec1565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610c93576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8a90611f53565b60405180910390fd5b610c9e838383611290565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610d24576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1b90611fe5565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e129190611735565b60405180910390a3610e25848484611295565b50505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16148015610ea757507f000000000000000000000000000000000000000000000000000000000000000046145b15610ed4577f00000000000000000000000000000000000000000000000000000000000000009050610f42565b610f3f7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061129a565b90505b90565b610f4d610958565b73ffffffffffffffffffffffffffffffffffffffff16610f6b6105b6565b73ffffffffffffffffffffffffffffffffffffffff1614610fc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb890612051565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611032576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611029906120bd565b60405180910390fd5b61103e60008383611290565b80600260008282546110509190611a2e565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516111019190611735565b60405180910390a361111560008383611295565b5050565b6000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081600001549050919050565b600080600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905061123a816111df565b9150611245816112d4565b50919050565b600061125e611258610e2b565b836112ea565b9050919050565b60008060006112768787878761131d565b91509150611283816113ff565b8192505050949350505050565b505050565b505050565b600083838346306040516020016112b59594939291906120dd565b6040516020818303038152906040528051906020012090509392505050565b6001816000016000828254019250508190555050565b600082826040516020016112ff9291906121a8565b60405160208183030381529060405280519060200120905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c11156113585760006003915091506113f6565b60006001878787876040516000815260200160405260405161137d94939291906121df565b6020604051602081039080840390855afa15801561139f573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036113ed576000600192509250506113f6565b80600092509250505b94509492505050565b6000600481111561141357611412612224565b5b81600481111561142657611425612224565b5b031561156257600160048111156114405761143f612224565b5b81600481111561145357611452612224565b5b03611493576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148a9061229f565b60405180910390fd5b600260048111156114a7576114a6612224565b5b8160048111156114ba576114b9612224565b5b036114fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114f19061230b565b60405180910390fd5b6003600481111561150e5761150d612224565b5b81600481111561152157611520612224565b5b03611561576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115589061239d565b60405180910390fd5b5b50565b600081519050919050565b600082825260208201905092915050565b60005b8381101561159f578082015181840152602081019050611584565b60008484015250505050565b6000601f19601f8301169050919050565b60006115c782611565565b6115d18185611570565b93506115e1818560208601611581565b6115ea816115ab565b840191505092915050565b6000602082019050818103600083015261160f81846115bc565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006116478261161c565b9050919050565b6116578161163c565b811461166257600080fd5b50565b6000813590506116748161164e565b92915050565b6000819050919050565b61168d8161167a565b811461169857600080fd5b50565b6000813590506116aa81611684565b92915050565b600080604083850312156116c7576116c6611617565b5b60006116d585828601611665565b92505060206116e68582860161169b565b9150509250929050565b60008115159050919050565b611705816116f0565b82525050565b600060208201905061172060008301846116fc565b92915050565b61172f8161167a565b82525050565b600060208201905061174a6000830184611726565b92915050565b60008060006060848603121561176957611768611617565b5b600061177786828701611665565b935050602061178886828701611665565b92505060406117998682870161169b565b9150509250925092565b600060ff82169050919050565b6117b9816117a3565b82525050565b60006020820190506117d460008301846117b0565b92915050565b6000819050919050565b6117ed816117da565b82525050565b600060208201905061180860008301846117e4565b92915050565b60006020828403121561182457611823611617565b5b600061183284828501611665565b91505092915050565b6118448161163c565b82525050565b600060208201905061185f600083018461183b565b92915050565b61186e816117a3565b811461187957600080fd5b50565b60008135905061188b81611865565b92915050565b61189a816117da565b81146118a557600080fd5b50565b6000813590506118b781611891565b92915050565b600080600080600080600060e0888a0312156118dc576118db611617565b5b60006118ea8a828b01611665565b97505060206118fb8a828b01611665565b965050604061190c8a828b0161169b565b955050606061191d8a828b0161169b565b945050608061192e8a828b0161187c565b93505060a061193f8a828b016118a8565b92505060c06119508a828b016118a8565b91505092959891949750929550565b6000806040838503121561197657611975611617565b5b600061198485828601611665565b925050602061199585828601611665565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806119e657607f821691505b6020821081036119f9576119f861199f565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611a398261167a565b9150611a448361167a565b9250828201905080821115611a5c57611a5b6119ff565b5b92915050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611abe602583611570565b9150611ac982611a62565b604082019050919050565b60006020820190508181036000830152611aed81611ab1565b9050919050565b7f45524332305065726d69743a206578706972656420646561646c696e65000000600082015250565b6000611b2a601d83611570565b9150611b3582611af4565b602082019050919050565b60006020820190508181036000830152611b5981611b1d565b9050919050565b600060c082019050611b7560008301896117e4565b611b82602083018861183b565b611b8f604083018761183b565b611b9c6060830186611726565b611ba96080830185611726565b611bb660a0830184611726565b979650505050505050565b7f45524332305065726d69743a20696e76616c6964207369676e61747572650000600082015250565b6000611bf7601e83611570565b9150611c0282611bc1565b602082019050919050565b60006020820190508181036000830152611c2681611bea565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000611c89602683611570565b9150611c9482611c2d565b604082019050919050565b60006020820190508181036000830152611cb881611c7c565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000611d1b602483611570565b9150611d2682611cbf565b604082019050919050565b60006020820190508181036000830152611d4a81611d0e565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b6000611dad602283611570565b9150611db882611d51565b604082019050919050565b60006020820190508181036000830152611ddc81611da0565b9050919050565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b6000611e19601d83611570565b9150611e2482611de3565b602082019050919050565b60006020820190508181036000830152611e4881611e0c565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000611eab602583611570565b9150611eb682611e4f565b604082019050919050565b60006020820190508181036000830152611eda81611e9e565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b6000611f3d602383611570565b9150611f4882611ee1565b604082019050919050565b60006020820190508181036000830152611f6c81611f30565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611fcf602683611570565b9150611fda82611f73565b604082019050919050565b60006020820190508181036000830152611ffe81611fc2565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b600061203b602083611570565b915061204682612005565b602082019050919050565b6000602082019050818103600083015261206a8161202e565b9050919050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b60006120a7601f83611570565b91506120b282612071565b602082019050919050565b600060208201905081810360008301526120d68161209a565b9050919050565b600060a0820190506120f260008301886117e4565b6120ff60208301876117e4565b61210c60408301866117e4565b6121196060830185611726565b612126608083018461183b565b9695505050505050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b6000612171600283612130565b915061217c8261213b565b600282019050919050565b6000819050919050565b6121a261219d826117da565b612187565b82525050565b60006121b382612164565b91506121bf8285612191565b6020820191506121cf8284612191565b6020820191508190509392505050565b60006080820190506121f460008301876117e4565b61220160208301866117b0565b61220e60408301856117e4565b61221b60608301846117e4565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000612289601883611570565b915061229482612253565b602082019050919050565b600060208201905081810360008301526122b88161227c565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b60006122f5601f83611570565b9150612300826122bf565b602082019050919050565b60006020820190508181036000830152612324816122e8565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000612387602283611570565b91506123928261232b565b604082019050919050565b600060208201905081810360008301526123b68161237a565b905091905056fea26469706673582212205e8d7bb733a28b307c6266e71d7fce8f78067e564cdf5e388464ca543c2ea25b64736f6c63430008120033000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003545354000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035453540000000000000000000000000000000000000000000000000000000000',
    value: '0x0',
    to: null,
  },
});

/* Controller Mocks */
const approveERC20Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildApproveTransactionData(approvalSpenderMock, 100),
  },
});

const revokeERC20Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildApproveTransactionData(approvalSpenderMock, 0),
  },
});

const approveERC721Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildApproveTransactionData(approvalSpenderMock, 1),
  },
});

const revokeERC721Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildApproveTransactionData(ZERO_ADDRESS, 1),
  },
});

const decreaseAllowanceERC20Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildDecreaseAllowanceTransactionData(approvalSpenderMock, 100),
  },
});

const increaseAllowanceERC20Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildIncreaseAllowanceTransactionData(approvalSpenderMock, 100),
  },
  type: TransactionType.tokenMethodIncreaseAllowance,
});

const approveAllERC721Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildSetApproveForAllTransactionData(approvalSpenderMock, true),
  },
  type: TransactionType.tokenMethodSetApprovalForAll,
});

const revokeAllERC721Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildSetApproveForAllTransactionData(approvalSpenderMock, false),
  },
  type: TransactionType.tokenMethodSetApprovalForAll,
});

const approveERC20Permit2Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildPermit2ApproveTransactionData(
      permit2TokenMock,
      approvalSpenderMock,
      100,
      1746696740463,
    ),
  },
});

const revokeERC20Permit2Transaction = merge({}, baseApproveTransaction, {
  txParams: {
    data: buildPermit2ApproveTransactionData(
      permit2TokenMock,
      approvalSpenderMock,
      0,
      1746696740463,
    ),
  },
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createTransactionControllerMock = (transaction: any) =>
  merge({}, baseTransactionControllerMock, {
    engine: {
      backgroundState: {
        TransactionController: {
          transactions: [transaction],
        },
      },
    },
  });

export const approveERC20TransactionControllerMock =
  createTransactionControllerMock(approveERC20Transaction);
export const revokeERC20TransactionControllerMock =
  createTransactionControllerMock(revokeERC20Transaction);
export const approveERC721TransactionControllerMock =
  createTransactionControllerMock(approveERC721Transaction);
export const revokeERC721TransactionControllerMock =
  createTransactionControllerMock(revokeERC721Transaction);
export const decreaseAllowanceERC20TransactionControllerMock =
  createTransactionControllerMock(decreaseAllowanceERC20Transaction);
export const increaseAllowanceERC20TransactionControllerMock =
  createTransactionControllerMock(increaseAllowanceERC20Transaction);
export const approveAllERC721TransactionControllerMock =
  createTransactionControllerMock(approveAllERC721Transaction);
export const revokeAllERC721TransactionControllerMock =
  createTransactionControllerMock(revokeAllERC721Transaction);
export const approveERC20Permit2TransactionControllerMock =
  createTransactionControllerMock(approveERC20Permit2Transaction);
export const revokeERC20Permit2TransactionControllerMock =
  createTransactionControllerMock(revokeERC20Permit2Transaction);
export const simpleSendTransactionControllerMock =
  createTransactionControllerMock(simpleSendTransaction);
export const erc20ContractDeploymentTransactionControllerMock =
  createTransactionControllerMock(contractDeploymentTransaction);
